package com.project.bean;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.List;

/**
 * 项目实体
 */
public class ProjectBean {
    /**项目id*/
    private int projectId;
    /**项目名称*/
    private String projectName;
    /**客户名称*/
    private String customerName;
    /**项目资金*/
    private int projectMoney;
    /**启动时间*/
    private LocalDate startDate = LocalDate.now();
    /**交付时间*/
    private LocalDate deliveryDate;
    /**还剩天数*/
    private String numDate;
    /**状态*/
    private String projectState = "开发中";
    /**项目参与人数*/
    private int joinNum;
    /**员工集合*/
    private List<ProgressBean> EmployeeList;

    public ProjectBean(String projectName, String customerName, int projectMoney,
                       LocalDate deliveryDate) {
        this.projectName = projectName;
        this.customerName = customerName;
        this.projectMoney = projectMoney;
        this.deliveryDate = deliveryDate;
    }

    public ProjectBean() {
    }

    public int getProjectId() {
        return projectId;
    }

    public void setProjectId(int projectId) {
        this.projectId = projectId;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public int getProjectMoney() {
        return projectMoney;
    }

    public void setProjectMoney(int projectMoney) {
        this.projectMoney = projectMoney;
    }

    public LocalDate getStartDate() {
        return startDate;
    }

    public void setStartDate(LocalDate startDate) {
        this.startDate = startDate;
    }

    public LocalDate getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(LocalDate deliveryDate) {
        this.deliveryDate = deliveryDate;
    }

    public String getNumDate() {
        //----计算剩余天数
        //判断项目的状态。如果是“交付使用”，则返回“已交付”
        //否则，计算剩余天数
        if (this.projectState=="交付使用"){
            return numDate = "已交付";
        }
        else {
            return numDate = ChronoUnit.DAYS.between(LocalDate.now(),this.deliveryDate)+"";
        }
    }

    public String getProjectState() {
        return projectState;
    }

    public void setProjectState(String projectState) {
        this.projectState = projectState;
    }

    public int getJoinNum() {
        return joinNum;
    }

    public void setJoinNum(int joinNum) {
        this.joinNum = joinNum;
    }

    public List<ProgressBean> getEmployeeList() {
        return EmployeeList;
    }

    public void setEmployeeList(List<ProgressBean> employeeList) {
        EmployeeList = employeeList;
    }

    @Override
    public String toString() {
        return "ProjectBean{" +
                "projectId=" + projectId +
                ", projectName='" + projectName + '\'' +
                ", customerName='" + customerName + '\'' +
                ", projectMoney=" + projectMoney +
                ", startDate=" + startDate +
                ", deliveryDate=" + deliveryDate +
                ", numDate='" + numDate + '\'' +
                ", projectState='" + projectState + '\'' +
                ", joinNum=" + joinNum +
                ", EmployeeList=" + EmployeeList +
                '}'+"\n";
    }
}
